//
//  HMSegmentedControlViewController.m
//  LianXi7.11
//
//  Created by apple on 2017/7/12.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HMSegmentedControlViewController.h"
#import <HMSegmentedControl.h>
@class FirstViewController;
@interface HMSegmentedControlViewController ()

@end

@implementation HMSegmentedControlViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    HMSegmentedControl *hms = [[HMSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 320, 49)];
    
    hms.sectionTitles = @[@"今日", @"明日"];
    //    hms.borderType = HMSegmentedControlBorderTypeBottom;
    hms.selectionStyle = UITableViewCellSelectionStyleBlue;
    hms.selectionIndicatorHeight = 3;
    hms.selectionIndicatorColor = [UIColor greenColor];
    //    hms.selectedTitleTextAttributes =
    [hms setTitleFormatter:^NSAttributedString *(HMSegmentedControl *segmentedControl, NSString *title, NSUInteger index, BOOL selected) {
        UIColor *color = selected? [UIColor blueColor]: [UIColor redColor];
        UIFont *font = [UIFont systemFontOfSize:16];
        NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:color, NSFontAttributeName:font}];
        return attString;
    }];
    
    hms.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
    hms.autoresizingMask = UIViewAutoresizingNone;
    
    //    [self.navigationController.navigationBar addSubview:hms];
    [self.view addSubview:hms];
    
    [self createBtnBack];
}

- (void)createBtnBack{
    
    UIButton *btnBack = [[UIButton alloc] initWithFrame:CGRectMake(30, 440, 50, 50)];
    
    [btnBack setTitle:@"BACK" forState:UIControlStateNormal];
    [btnBack setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    
    btnBack.backgroundColor = [UIColor greenColor];
    
    [btnBack addTarget:self action:@selector(btnBack) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btnBack];
    
}

- (void)btnBack{
    
    [self dismissViewControllerAnimated:YES completion:nil];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
